package dataconvert

/**
 * @author: kevin  
 * @date: 11:11 2021/4/30
 */
object StringToBasic {
  def main(args: Array[String]): Unit = {
    val d1 = 1.2
    //值类型转换为String类型
    val s1 = d1 + ""

    val str = "23"
    val num = str.toInt
    val num2 = str.toFloat
    val num3 = str.toDouble
    val num4 = str.toLong

    val s3 = "hello"
    println(s3.toInt) //error

    //在Scala中，不是将小数点后的数据进行截取，而是会排除异常
    val s4 = "12.5"
    println(s4.toInt) //error

  }
}
